--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\tmoore\Dropbox\Evans and Moore Crack Working Paper\Submission_ReSTAT\code_data\Education\educationresults.log
  log type:  text
 opened on:  30 Jun 2016, 18:48:58

. 
. clear all

. estimates clear

. 
end of do-file

. do "C:\Users\tmoore\AppData\Local\Temp\STD0f000000.tmp"

. 
. *** Data from 2000 5% PUMS organized for MSA analysis
. use current_msa_2000.dta, clear

. rename yearturn18 cohort

. sort metaread /*MSA identifier*/

. merge metaread using when_crack_arrives_msa_5_3_2012 /*Merged with MSA crack arrival dates*/
(note: you are using old merge syntax; see [D] merge for new syntax)
variable metaread does not uniquely identify observations in the master data

. drop if crack_arrives==.
(1,155,237 observations deleted)

. 
. * HS graduation in relation to crack arrival
. gen index=cohort-crack_arrives

. keep if index>=-8 & index<=8
(594,725 observations deleted)

. sort metaread sex race index 

. 
. collapse hsgrad [aw=perwt], by(race sex index)

. 
. *** Means for Panel A - Race differences for males
. preserve 

. keep if sex==1
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using msa_hsgrad_male_byrace_crack_arrival, replace
file msa_hsgrad_male_byrace_crack_arrival.xls saved

. restore

. 
. *** Means for Panel B - Race differences for females
. preserve

. keep if sex==2
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using msa_hsgrad_male_byrace_crack_arrival, replace
file msa_hsgrad_male_byrace_crack_arrival.xls saved

. restore

. 
. 
. ************************************************
. *** State-of-birth analysis - Panels C and D ***
. ************************************************
. 
. *** Data from 2000 5% PUMS organized by state of birth
. use sob_2000_pums.dta, clear

. rename yearturn18 cohort

. sort fips /*state identifier*/

. merge fips using when_crack_arrives_5_3_2012 /*Merged with state crack arrival dates*/
(note: you are using old merge syntax; see [D] merge for new syntax)
variable fips does not uniquely identify observations in the master data

. drop if crack_arrives==.
(133,144 observations deleted)

. 
. * HS graduation in relation to crack arrival
. gen index=cohort-crack_arrives

. keep if index>=-8 & index<=8
(1,433,975 observations deleted)

. sort fips sex race index 

. 
. collapse hsgrad [aw=perwt], by(fips race sex index)

. 
. *** Means for Panel C - Race differences for males
. preserve 

. keep if sex==1
(1,394 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)
values of variable race not unique within index
    Your data are currently long.  You are performing a reshape wide.  You specified i(index) and j(race).  There are observations within i(index) with the same value of j(race).  In the long data,
    variables i() and j() together must uniquely identify the observations.

         long                                wide
        +---------------+                   +------------------+
        | i   j   a   b |                   | i   a1 a2  b1 b2 |
        |---------------| <--- reshape ---> |------------------|
        | 1   1   1   2 |                   | 1   1   3   2  4 |
        | 1   2   3   4 |                   | 2   5   7   6  8 |
        | 2   1   5   6 |                   +------------------+
        | 2   2   7   8 |
        +---------------+
    Type reshape error for a list of the problem variables.
r(9);

end of do-file

r(9);

. do "C:\Users\tmoore\AppData\Local\Temp\STD0f000000.tmp"

. 
. *** Data from 2000 5% PUMS organized for MSA analysis
. use current_msa_2000.dta, clear

. rename yearturn18 cohort

. sort metaread /*MSA identifier*/

. merge metaread using when_crack_arrives_msa_5_3_2012 /*Merged with MSA crack arrival dates*/
(note: you are using old merge syntax; see [D] merge for new syntax)
variable metaread does not uniquely identify observations in the master data

. drop if crack_arrives==.
(1,155,237 observations deleted)

. 
. * HS graduation in relation to crack arrival
. gen index=cohort-crack_arrives

. keep if index>=-8 & index<=8
(594,725 observations deleted)

. sort metaread sex race index 

. 
. collapse hsgrad [aw=perwt], by(race sex index)

. 
. *** Means for Panel A - Race differences for males
. preserve 

. keep if sex==1
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using msa_hsgrad_male_byrace_crack_arrival, replace
file msa_hsgrad_male_byrace_crack_arrival.xls saved

. restore

. 
. *** Means for Panel B - Race differences for females
. preserve

. keep if sex==2
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using msa_hsgrad_female_byrace_crack_arrival, replace
file msa_hsgrad_female_byrace_crack_arrival.xls saved

. restore

. 
. 
. ************************************************
. *** State-of-birth analysis - Panels C and D ***
. ************************************************
. 
. *** Data from 2000 5% PUMS organized by state of birth
. use sob_2000_pums.dta, clear

. rename yearturn18 cohort

. sort fips /*state identifier*/

. merge fips using when_crack_arrives_5_3_2012 /*Merged with state crack arrival dates*/
(note: you are using old merge syntax; see [D] merge for new syntax)
variable fips does not uniquely identify observations in the master data

. drop if crack_arrives==.
(133,144 observations deleted)

. 
. * HS graduation in relation to crack arrival
. gen index=cohort-crack_arrives

. keep if index>=-8 & index<=8
(1,433,975 observations deleted)

. sort fips sex race index 

. 
. collapse hsgrad [aw=perwt], by(race sex index)

. 
. *** Means for Panel C - Race differences for males
. preserve 

. keep if sex==1
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using state_hsgrad_male_byrace_crack_arrival, replace
file state_hsgrad_male_byrace_crack_arrival.xls saved

. restore

. 
. *** Means for Panel D - Race differences for females
. preserve

. keep if sex==2
(34 observations deleted)

. drop sex

. reshape wide hsgrad, i(index) j(race)
(note: j = 1 2)

Data                               long   ->   wide
-----------------------------------------------------------------------------
Number of obs.                       34   ->      17
Number of variables                   3   ->       3
j variable (2 values)              race   ->   (dropped)
xij variables:
                                 hsgrad   ->   hsgrad1 hsgrad2
-----------------------------------------------------------------------------

. rename hsgrad1 hsgrad_white

. rename hsgrad2 hsgrad_black

. export excel using state_hsgrad_female_byrace_crack_arrival, replace
file state_hsgrad_female_byrace_crack_arrival.xls saved

. restore

. 
end of do-file

. exit, clear
